<div class="widget statistics">
    <?php
    $counter = 0;
    $results = Statistics::model()->findAll();
    /* Get data total member */
    $criteria = new CDbCriteria;
    $criteria->condition = 'role=:role';
    $criteria->params = array(':role' => 'user');
    $users = User::model()->findAll($criteria);
    
    if ($results != null && count($results) > 0) {
        if (!isset(Yii::app()->session['statistics'])) {
            $results[0]->customer_view_counter += 1;
            
            $transaction = $results[0]->getDbConnection()->beginTransaction();
            try {
                $results[0]->save();
                $transaction->commit();
            } catch (Exception $ex) {
                $transaction->rollback();
            }
            
            /* Add data number view in day */
            $obj = new StatisticsTime();
            $obj->timestamp = time();
            $transaction = $obj->getDbConnection()->beginTransaction();
            try {
                $obj->save();
                $transaction->commit();
            } catch (Exception $ex) {
                //var_dump($ex->getMessage());
            }
            /* Get data number view in day */
        }
        $counter = $results[0]->customer_view_counter;
        Yii::app()->session['statistics'] = $counter;
    }
    $today = getdate();
    //$str_date= $today['year'].'-'.$today['mon'].'-'.$today['mday'].' 00:00:00';
    //$date = new DateTime($str_date);
    //$timestamp=$date->getTimestamp();
    $timestamp=mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);
    $views = StatisticsTime::model()->findAll("timestamp > $timestamp");
    $views = count($views) + 100;
    ?>
    <div class="gradient">
        <div class="label">
            <span><?php echo Yii::t('default', 'Statistics') ?></span>
        </div>
        <ul class="statistics-section">
            <li><?php echo Yii::t('default', 'Total view') ?>
                <span><?php echo $counter ?></span>
            </li>
         <!--
            <li><?php echo Yii::t('default', 'Total member') ?>
                <span><?php echo count($users) ?></span>
            </li>
         -->
            <li><?php echo Yii::t('default', 'Number view in day') ?>
                <span><?php echo $views ?></span>
            </li>
        </ul>
     <!--
        <div class="digits content">
            <div>
                <?php $digits = Util::getDigits($counter) ?>
                <?php foreach($digits as $digit): ?>
                <div class="digit">
                    <span><?php echo $digit ?></span>
                </div>
                <?php endforeach ?>
            </div>
        </div>
     -->
    </div>
</div>